package org.mnj07.struts.hello;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HelloWorld {
  private String message;

  private String userName;

  private String detail;

  private String city;
 
  private String zipcode;
  
  private  String[] sampleArray = {"item1","item2","item3"};

  private  List<String> sampleList = new ArrayList<String>();
  
  private  Map<Integer,String> sampleMap = new HashMap<Integer,String>();
  
  private Car car = new Car();
  
  public HelloWorld() {
      sampleList.add("listItem1");
      sampleList.add("listItem2");
      sampleList.add("listItem3");
      
      sampleMap.put(new Integer(1), "one");
      sampleMap.put(new Integer(2), "two");
      sampleMap.put(new Integer(3), "three");     
      
      car.setName("Honda Accord");
  }
  
  public String execute() {
    String text = "Hello " + getUserName();
    String c = getCity();
    if(c != null && !"".equals(c)){
      text += (" from " + c);
    }
    text += " !";
    setMessage(text);
    Calendar now = Calendar.getInstance();
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd KK:mm a");
    String formattedDate = dateFormat.format(now.getTime());
    setDetail(formattedDate);
    //return "SUCCESS";
     return "DETAILED-SUCCESS";
  }

  /**
   * @return the message
   */
  public String getMessage() {
    return message;
  }

  /**
   * @param message
   *          the message to set
   */
  public void setMessage(String message) {
    this.message = message;
  }

  /**
   * @return the userName
   */
  public String getUserName() {
    return userName;
  }

  /**
   * @param userName
   *          the userName to set
   */
  public void setUserName(String userName) {
    this.userName = userName;
  }

  /**
   * @param detail
   *          string
   */
  public String getDetail() {
    return detail;
  }

  /**
   * @return the detail
   */
  public void setDetail(String detail) {
    this.detail = detail;
  }
 
  public String getCity() {
    return city;
  }

  public void setCity(String city) {
    this.city = city;
  }

  public String getZipcode() {
    return zipcode;
  }

  public void setZipcode(String zipcode) {
    this.zipcode = zipcode;
  }
  
  public String[] getSampleArray() {
    return sampleArray;
  }
  
  public void setSampleArray(String[] sampleArray) {
    this.sampleArray = sampleArray;
  }
  
  public List<String> getSampleList() {
    return sampleList;
  }
  
  public void setSampleList(List<String> sampleList) {
    this.sampleList = sampleList;
  }
  
  public Map<Integer, String> getSampleMap() {
    return sampleMap;
  }
  
  public void setSampleMap(Map<Integer, String> sampleMap) {
    this.sampleMap = sampleMap;
  }  
  
  public String hello(){
    return "output from calling hello()";
  }
}
